package com.shaoshaohuo.app.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.shaoshaohuo.app.R;
import com.shaoshaohuo.app.entity.FragmentNewCarEntity;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Administrator on 2017/6/23.
 */

public class FinishPayOrderDetailsAdapter extends BaseAdapter {
    private Context context;
    private List<FragmentNewCarEntity.DataBean> sure_order_shop_data;

    public FinishPayOrderDetailsAdapter(Context context, List<FragmentNewCarEntity.DataBean> sure_order_shop_data) {
        this.context = context;
        this.sure_order_shop_data = sure_order_shop_data;
    }

    @Override
    public int getCount() {
        return sure_order_shop_data != null ? sure_order_shop_data.size() : 0;
    }

    @Override
    public Object getItem(int position) {
        return sure_order_shop_data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        FinishPayOrderDetailsViewHolder holder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.finish_pay_shop_details, parent, false);
            holder = new FinishPayOrderDetailsViewHolder();
            holder.finish_pay_details_mbn_details = (TextView) convertView.findViewById(R.id.finish_pay_details_mbn_details);
            holder.finish_pay_details_money = (TextView) convertView.findViewById(R.id.finish_pay_details_money);
            holder.finish_pay_details_name = (TextView) convertView.findViewById(R.id.finish_pay_details_name);
            holder.finish_pay_details_picture = (ImageView) convertView.findViewById(R.id.finish_pay_details_picture);
            holder.finish_pay_details_details = (TextView) convertView.findViewById(R.id.finish_pay_details_details);
            convertView.setTag(holder);
        } else {
            holder = (FinishPayOrderDetailsViewHolder) convertView.getTag();
        }
        holder.finish_pay_details_money.setText(sure_order_shop_data.get(position).getPrice());
        holder.finish_pay_details_name.setText(sure_order_shop_data.get(position).getNames());
        holder.finish_pay_details_mbn_details.setText(sure_order_shop_data.get(position).getMbn_details()+"");
        holder.finish_pay_details_details.setText(sure_order_shop_data.get(position).getDetails());
        Picasso.with(context).load(sure_order_shop_data.get(position).getImg()).into(holder.finish_pay_details_picture);
        return convertView;
    }


    class FinishPayOrderDetailsViewHolder {
        TextView finish_pay_details_money;
        TextView finish_pay_details_mbn_details;
        TextView finish_pay_details_details;
        TextView finish_pay_details_name;
        ImageView finish_pay_details_picture;
    }
}
